package com.ww.dao.impl;

import com.ww.dao.MenuDao;
import com.ww.entity.Goods;
import com.ww.entity.Menu;
import com.ww.util.DBUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class MenuDaoImpl implements MenuDao {
    Connection conn = DBUtil.getConnection();
    QueryRunner qr = new QueryRunner();

    @Override
    public int save(Menu obj) {
        return 0;
    }

    @Override
    public int update(Menu obj) {
        return 0;
    }

    @Override
    public int delete(Object id) {
        return 0;
    }

    @Override
    public Menu findById(Object key) {
        return null;
    }

    @Override
    public List<Menu> findAll() {
        String sql = "SELECT * FROM tb_menu";
        Object[] paras = {};
        try {
            List<Menu> menuList = qr.query(conn, sql, paras, new BeanListHandler<Menu>(Menu.class));
            return menuList;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public List<Menu> findSearch(String keyword) {
        return null;
    }

    @Override
    public List<Menu> findPage(int page, int pagesize) {
        return null;
    }

    @Override
    public long count() {
        return 0;
    }
}
